home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Commodities / CxKiller / CxKiller.c < prev    next >
C/C++ Source or Header  |  1996-09-26  |  3KB  |  115 lines

  1. /*
  2. **  CxKiller.c : Gael Marziou
  3. **
  4. **  A simple program to kill Commodties safely.
  5. **  Without any argument it kills all commodities.
  6. **  Arguments must be a list of Commodities.names
  7. **  Names are case sensitive.
  8. **
  9. **  29 Nov. 93
  10. **  09 Jan. 94 -- Mike Cuddy (fensende!mcuddy@apple.com)
  11. **        added 'DISABLE/ENABLE' argument (as first arg), to send
  12. **        CXCMD_DISABLE / CXCMD_ENABLE instead of CXCMD_KILL
  13. */
  14.  
  15. #include <exec/libraries.h>
  16. #include <exec/memory.h>
  17. #include <libraries/commodities.h>
  18. #include <dos/dos.h>
  19. #include <string.h>
  20. #include <clib/exec_protos.h>
  21. #include <clib/alib_protos.h>
  22. #include <clib/commodities_protos.h>
  23.  
  24. UBYTE *version = "$VER: CxKiller 1.2";
  25.  
  26. #ifdef __SASC
  27. int CXBRK(void) { return(0); }  /* Disable SAS_C CTRL/C handling */
  28. int chkabort(void) { return(0); } 
  29. #include <pragmas/commodities_pragmas.h>
  30. #include <pragmas/exec_pragmas.h>
  31. #include <pragmas/dos_pragmas.h>
  32. #endif
  33.  
  34. /*** private functions of "commodities.library" ***/
  35.  
  36. #pragma libcall CxBase FindBroker 6c 801
  37. #pragma libcall CxBase CopyBrokerList ba 801
  38. #pragma libcall CxBase FreeBrokerList c0 801
  39. #pragma libcall CxBase BrokerCommand c6 802
  40.  
  41. CxObj *FindBroker(char *);
  42. LONG CopyBrokerList(struct List *);
  43. LONG FreeBrokerList(struct List *);
  44. LONG BrokerCommand(char *, LONG id);
  45.  
  46. struct Library *CxBase;
  47.  
  48. /*** private structures & defines ***/
  49.  
  50. struct BrokerCopy    {
  51.     struct Node    bc_Node;
  52.     char    bc_Name[CBD_NAMELEN];
  53.     char    bc_Title[CBD_TITLELEN];
  54.     char    bc_Descr[CBD_DESCRLEN];
  55.     LONG    bc_Task;
  56.     LONG    bc_Dummy1;
  57.     LONG    bc_Dummy2;
  58.     UWORD    bc_Flags;
  59. };
  60.  
  61. #define COF_ACTIVE 2
  62.  
  63.  
  64. __inline void 
  65. SendToAllBrokers (LONG Id)
  66. {
  67.     struct List *l;
  68.     struct Node *n, *nn;
  69.  
  70.     if (l = AllocVec(sizeof(struct List),MEMF_PUBLIC)) {
  71.         NewList(l);
  72.         CopyBrokerList(l);
  73.         for (n = l->lh_Head; n && (nn = n->ln_Succ); n = nn)
  74.             BrokerCommand((char *)((struct BrokerCopy *)n)->bc_Name,Id);
  75.         FreeBrokerList(l);
  76.         FreeVec(l);
  77.     }
  78. }
  79.  
  80. void 
  81. main(int argc, char *argv[])
  82. {
  83.     unsigned char i;
  84.     LONG Id = CXCMD_KILL;
  85.  
  86.     /* Before bothering with anything else, open the library */
  87.     if (CxBase = OpenLibrary("commodities.library", 37L))
  88.     {
  89.         if (argv[1]) {
  90.             if (stricmp(argv[1],"DISABLE")==0) {
  91.             Id = CXCMD_DISABLE;
  92.             argv++; argc--;
  93.             } else if (stricmp(argv[1],"ENABLE")==0) {
  94.             Id = CXCMD_ENABLE;
  95.             argv++; argc--;
  96.             }
  97.         }
  98.         if (argc < 2) 
  99.         {    /* no argument given, send to all brokers. */
  100.             SendToAllBrokers(Id);
  101.         }
  102.         else
  103.         {
  104.             for (i=1; i<argc ; i++)
  105.             {
  106.                 BrokerCommand((char *)argv[i], Id);
  107.             }
  108.         }
  109.     }
  110.     CloseLibrary(CxBase);
  111. }
  112.  
  113.  
  114.  
  115.